###########################################################################################
# 
# Prepare List Experiments and Test for No Design Effects
#
########################################################################################

### Democratic Republic of Congo

table(congo$rape_yes)

congo$direct <- congo$rape_yes

dir.congo <- lm(direct ~ 1, data=congo) # Direct Item
c.dir.congo <- coef(dir.congo)[1]
se.dir.congo <- se.coef(dir.congo)[1]

c.diff.congo <- coef(dir.congo)[1] - coef(ind.congo)[2] # Difference Direct - Indirect
se.diff.congo <- sqrt(se.coef(dir.congo)[1]^2 + se.coef(ind.congo)[2]^2)

########################################################################################

### Liberia

table(liberia$cw_crsv1)
table(liberia$cw_crsv2)

liberia$direct.1 <- liberia$cw_crsv1
liberia$direct.2 <- liberia$cw_crsv2

dir.1.liberia <- lm(direct.1 ~ 1, data=liberia)  # Direct Item 1
c.dir.liberia <- coef(dir.1.liberia)
se.dir.liberia <- se.coef(dir.1.liberia)

dir.2.liberia <- lm(direct.2 ~ 1, data=liberia)  # Direct Item 2
coef(dir.2.liberia)
se.coef(dir.2.liberia)

c.diff.liberia <- coef(dir.1.liberia)[1] - coef(ind.liberia)[2] # Difference Direct 1 - Indirect
se.diff.liberia <- sqrt(se.coef(dir.1.liberia)[1]^2 + se.coef(ind.liberia)[2]^2)

coef(dir.2.liberia)[1] - coef(ind.liberia)[2]
sqrt(se.coef(dir.2.liberia)[1]^2 + se.coef(ind.liberia)[2]^2)

########################################################################################

### Sri Lanka

sri$direct.1 <- ifelse(sri$D4h==77, NA, sri$D4h)
sri$direct.1 <- ifelse(sri$direct.1==2, 0, sri$direct.1)

dir.1.sri <- lm(direct.1 ~ 1, data=sri)  # Direct Item 1
c.dir.sri <- coef(dir.1.sri)[1]
se.dir.sri <- se.coef(dir.1.sri)[1]

sri$direct.2 <- ifelse(sri$D4i==77, NA, sri$D4i)
sri$direct.2 <- ifelse(sri$direct.2==2, 0, sri$direct.2)

dir.2.sri <- lm(direct.2 ~ 1, data=sri) # Direct Item 2
coef(dir.2.sri)
se.coef(dir.2.sri)

c.diff.sri <- coef(dir.1.sri)[1] - coef(ind.sri)[2] # Difference Direct 1 - Indirect
se.diff.sri <- sqrt(se.coef(dir.1.sri)[1]^2 + se.coef(ind.sri)[2]^2)

coef(dir.2.sri)[1] - coef(ind.sri)[2]
sqrt(se.coef(dir.2.sri)[1]^2 + se.coef(ind.sri)[2]^2)

########################################################################################
